package coml.jiyun.hp.reviewtopic.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
import coml.jiyun.hp.reviewtopic.FlowLayout;
import coml.jiyun.hp.reviewtopic.R;
import coml.jiyun.hp.reviewtopic.base.BaseRlvAdapter;
import coml.jiyun.hp.reviewtopic.bean.NaviBean;

public class FlowNaviAdapter extends BaseRlvAdapter<NaviBean.DataBean> {

    public List<NaviBean.DataBean.ArticlesBean> articlesBeans = new ArrayList<>();


    public FlowNaviAdapter(Context context, List<NaviBean.DataBean> list) {
        super(context, list);
    }

    @Override
    protected void bindData(BaseViewHolder holder, NaviBean.DataBean dataBean) {
        FlowLayout fl = (FlowLayout) holder.itemView;
        final List<NaviBean.DataBean.ArticlesBean> articles = dataBean.getArticles();

        for (int i = 0; i < articles.size() ; i++) {
            final NaviBean.DataBean.ArticlesBean articlesBean = articles.get(i);
            TextView tv = (TextView) LayoutInflater.from(mContext).inflate(R.layout.item_flow_system, null);
            tv.setText(articlesBean.getTitle());
            fl.addView(tv);
        }

        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                onItemClick.dj(view);
            }
        });
    }

    @Override
    protected int getLayout() {
        return R.layout.item_navi;
    }

    public interface onItemClick{
        void dj(View i);
    }

    onItemClick onItemClick;

    public void setOnItemClick(FlowNaviAdapter.onItemClick onItemClick) {
        this.onItemClick = onItemClick;
    }
}